﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Services;
using CRM.UTIL;
using System.Collections;

namespace CRM.WEB.WebService
{
    /// <summary>
    /// WSOrderInfoList 的摘要说明
    /// </summary>
    [WebService(Namespace = "http://tempuri.org/")]
    [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
    [System.ComponentModel.ToolboxItem(false)]
    // 若要允许使用 ASP.NET AJAX 从脚本中调用此 Web 服务，请取消对下行的注释。
    // [System.Web.Script.Services.ScriptService]
    public class WSOrderInfoList : System.Web.Services.WebService
    {

        [WebMethod]
        public string HelloWorld()
        {
            return "Hello World";
        }
        [WebMethod] //获取全部数据
        public int EditOrderInfo(string json, string action)
        {
            string sql = string.Empty;
            int flag = 0;
            if (string.IsNullOrEmpty(json) || string.IsNullOrEmpty(action))
            {
                return flag = 3;
            }
            object o = JSON.Decode(json);
            ArrayList al = o as ArrayList;
          
            //操作业务
            MODEL.EditOrderInfo eoi = new MODEL.EditOrderInfo();
            BLL.Role.OrderInfoB obj = new BLL.Role.OrderInfoB();
            if (al != null)
            {
                if (action == "Insert")//新增
                {
                    Hashtable result = null;

                    for (int i = 0; i < al.Count; i++)
                    {
                        result = al[i] as Hashtable;

                        foreach (DictionaryEntry de in result)
                        {
                            if (de.Key.ToString() == "OrderNO")
                            {
                                eoi.ORDERNO_VALUE = de.Value.ToString();
                            }
                            if (de.Key.ToString() == "GuaranteeNO")
                            {
                                eoi.GUARANTEENO_VALUE = de.Value.ToString();
                            }
                            if (de.Key.ToString() == "BuyerID")
                            {
                                eoi.BUYERID_VALUE = de.Value.ToString();
                            }
                            if (de.Key.ToString() == "BuyerFullName")
                            {
                                eoi.BUYERFULLNAME_VALUE = de.Value.ToString();
                            }
                            if (de.Key.ToString() == "BuyerAdd")
                            {
                                eoi.BUYERADD_VALUE = de.Value.ToString();
                            }
                            if (de.Key.ToString() == "BuyerTel")
                            {
                                eoi.BUYERTEL_VALUE = de.Value.ToString();
                            }
                            if (de.Key.ToString() == "OrderDate")
                            {
                                eoi.ORDERDATE_VALUE = de.Value.ToString();
                            }
                            if (de.Key.ToString() == "DeliveryDate")
                            {
                                eoi.DELIVERYDATE_VALUE = de.Value.ToString();
                            }

                            if (de.Key.ToString() == "ProductTitle")
                            {
                                eoi.PRODUCTTITLE_VALUE = de.Value.ToString();
                            }
                            if (de.Key.ToString() == "ProductModel")
                            {
                                eoi.PRODUCTMODEL_VALUE = de.Value.ToString();
                            }
                            if (de.Key.ToString() == "ProductBrand")
                            {
                                eoi.PRODUCTBRAND_VALUE = de.Value.ToString();
                            }
                            if (de.Key.ToString() == "ProductColor")
                            {
                                eoi.PRODUCTCOLOR_VALUE = de.Value.ToString();
                            }
                            if (de.Key.ToString() == "RAM")
                            {
                                eoi.RAM_VALUE = de.Value.ToString();
                            }

                            if (de.Key.ToString() == "ROM")
                            {
                                eoi.ROM_VALUE = de.Value.ToString();
                            }
                            if (de.Key.ToString() == "Network4G")
                            {
                                eoi.NETWORK4G_VALUE = de.Value.ToString();
                            }
                            if (de.Key.ToString() == "Band4G")
                            {
                                eoi.BAND4G_VALUE = de.Value.ToString();
                            }
                            if (de.Key.ToString() == "Network3G")
                            {
                                eoi.NETWORK3G_VALUE = de.Value.ToString();
                            }
                            if (de.Key.ToString() == "Band3G")
                            {
                                eoi.BAND3G_VALUE = de.Value.ToString();
                            }
                            if (de.Key.ToString() == "Network2G")
                            {
                                eoi.NETWORK2G_VALUE = de.Value.ToString();
                            }
                            if (de.Key.ToString() == "Band2G")
                            {
                                eoi.BAND2G_VALUE = de.Value.ToString();
                            }
                        }
                        eoi.ACTION_VALUE = "Insert";
                        eoi.ISDEL_VALUE = "N";
                        flag += obj.EditOrderInfoModule(ref eoi);
                    }
                    LogHelper.WriteLog(typeof(Nullable), "时间:" + DateTime.Now + "</n>" + "操作:" + action + "</n>" + "json:" + json);
                }

                if (action == "Update")//新增
                {
                    Hashtable result = null;

                    for (int i = 0; i < al.Count; i++)
                    {
                        result = al[i] as Hashtable;

                        foreach (DictionaryEntry de in result)
                        {
                            if (de.Key.ToString() == "OrderNO")
                            {
                                eoi.ORDERNO_VALUE = de.Value.ToString();
                            }
                            if (de.Key.ToString() == "GuaranteeNO")
                            {
                                eoi.GUARANTEENO_VALUE = de.Value.ToString();
                            }
                            if (de.Key.ToString() == "BuyerID")
                            {
                                eoi.BUYERID_VALUE = de.Value.ToString();
                            }
                            if (de.Key.ToString() == "BuyerFullName")
                            {
                                eoi.BUYERFULLNAME_VALUE = de.Value.ToString();
                            }
                            if (de.Key.ToString() == "BuyerAdd")
                            {
                                eoi.BUYERADD_VALUE = de.Value.ToString();
                            }
                            if (de.Key.ToString() == "BuyerTel")
                            {
                                eoi.BUYERTEL_VALUE = de.Value.ToString();
                            }
                            if (de.Key.ToString() == "OrderDate")
                            {
                                eoi.ORDERDATE_VALUE = de.Value.ToString();
                            }
                            if (de.Key.ToString() == "DeliveryDate")
                            {
                                eoi.DELIVERYDATE_VALUE = de.Value.ToString();
                            }

                            if (de.Key.ToString() == "ProductTitle")
                            {
                                eoi.PRODUCTTITLE_VALUE = de.Value.ToString();
                            }
                            if (de.Key.ToString() == "ProductModel")
                            {
                                eoi.PRODUCTMODEL_VALUE = de.Value.ToString();
                            }
                            if (de.Key.ToString() == "ProductBrand")
                            {
                                eoi.PRODUCTBRAND_VALUE = de.Value.ToString();
                            }
                            if (de.Key.ToString() == "ProductColor")
                            {
                                eoi.PRODUCTCOLOR_VALUE = de.Value.ToString();
                            }
                            if (de.Key.ToString() == "RAM")
                            {
                                eoi.RAM_VALUE = de.Value.ToString();
                            }

                            if (de.Key.ToString() == "ROM")
                            {
                                eoi.ROM_VALUE = de.Value.ToString();
                            }
                            if (de.Key.ToString() == "Network4G")
                            {
                                eoi.NETWORK4G_VALUE = de.Value.ToString();
                            }
                            if (de.Key.ToString() == "Band4G")
                            {
                                eoi.BAND4G_VALUE = de.Value.ToString();
                            }
                            if (de.Key.ToString() == "Network3G")
                            {
                                eoi.NETWORK3G_VALUE = de.Value.ToString();
                            }
                            if (de.Key.ToString() == "Band3G")
                            {
                                eoi.BAND3G_VALUE = de.Value.ToString();
                            }
                            if (de.Key.ToString() == "Network2G")
                            {
                                eoi.NETWORK2G_VALUE = de.Value.ToString();
                            }
                            if (de.Key.ToString() == "Band2G")
                            {
                                eoi.BAND2G_VALUE = de.Value.ToString();
                            }

                        }
                        eoi.ACTION_VALUE = "Update";
                        eoi.ISDEL_VALUE = "N";
                        flag += obj.EditOrderInfoModule(ref eoi);
                    }
                   
                }
                LogHelper.WriteLog(typeof(Nullable), "时间:" + DateTime.Now + "</n>" + "操作:" + action + "</n>" + "json:" + json);
            }

            if (action == "Delete")//删除
            {
                Hashtable result = null;

                for (int i = 0; i < al.Count; i++)
                {
                    result = al[i] as Hashtable;

                    foreach (DictionaryEntry de in result)
                    {
                        if (de.Key.ToString() == "OrderNO")
                        {
                            eoi.ORDERNO_VALUE = de.Value.ToString();
                        }
                        if (de.Key.ToString() == "GuaranteeNO")
                        {
                            eoi.GUARANTEENO_VALUE = de.Value.ToString();
                        }
                        if (de.Key.ToString() == "BuyerID")
                        {
                            eoi.BUYERID_VALUE = de.Value.ToString();
                        }
                        if (de.Key.ToString() == "BuyerFullName")
                        {
                            eoi.BUYERFULLNAME_VALUE = de.Value.ToString();
                        }
                        if (de.Key.ToString() == "BuyerAdd")
                        {
                            eoi.BUYERADD_VALUE = de.Value.ToString();
                        }
                        if (de.Key.ToString() == "BuyerTel")
                        {
                            eoi.BUYERTEL_VALUE = de.Value.ToString();
                        }
                        if (de.Key.ToString() == "OrderDate")
                        {
                            eoi.ORDERDATE_VALUE = de.Value.ToString();
                        }
                        if (de.Key.ToString() == "DeliveryDate")
                        {
                            eoi.DELIVERYDATE_VALUE = de.Value.ToString();
                        }

                        if (de.Key.ToString() == "ProductTitle")
                        {
                            eoi.PRODUCTTITLE_VALUE = de.Value.ToString();
                        }
                        if (de.Key.ToString() == "ProductModel")
                        {
                            eoi.PRODUCTMODEL_VALUE = de.Value.ToString();
                        }
                        if (de.Key.ToString() == "ProductBrand")
                        {
                            eoi.PRODUCTBRAND_VALUE = de.Value.ToString();
                        }
                        if (de.Key.ToString() == "ProductColor")
                        {
                            eoi.PRODUCTCOLOR_VALUE = de.Value.ToString();
                        }
                        if (de.Key.ToString() == "RAM")
                        {
                            eoi.RAM_VALUE = de.Value.ToString();
                        }

                        if (de.Key.ToString() == "ROM")
                        {
                            eoi.ROM_VALUE = de.Value.ToString();
                        }
                        if (de.Key.ToString() == "Network4G")
                        {
                            eoi.NETWORK4G_VALUE = de.Value.ToString();
                        }
                        if (de.Key.ToString() == "Band4G")
                        {
                            eoi.BAND4G_VALUE = de.Value.ToString();
                        }
                        if (de.Key.ToString() == "Network3G")
                        {
                            eoi.NETWORK3G_VALUE = de.Value.ToString();
                        }
                        if (de.Key.ToString() == "Band3G")
                        {
                            eoi.BAND3G_VALUE = de.Value.ToString();
                        }
                        if (de.Key.ToString() == "Network2G")
                        {
                            eoi.NETWORK2G_VALUE = de.Value.ToString();
                        }
                        if (de.Key.ToString() == "Band2G")
                        {
                            eoi.BAND2G_VALUE = de.Value.ToString();
                        }

                    }
                    eoi.ACTION_VALUE = "Delete";
                    eoi.ISDEL_VALUE = "N";
                    flag += obj.EditOrderInfoModule(ref eoi);
                }
                LogHelper.WriteLog(typeof(Nullable), "时间:" + DateTime.Now + "</n>" + "操作:" + action + "</n>" + "json:" + json);
            }
            if (flag > 0 && eoi.ERRMSG_VALUE.ToString() == "")
            {
                flag = 1;//成功
            }
            else
            {
                flag = 0;//失败
            }
            return flag;
        }
    }
}
